package com.jboost.common.file.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.jboost.common.constant.CommonConstant;
import com.jboost.common.constant.EnumInterface;

/**
 *@ClassName
 *@Description 视频码率枚举
 *@Author cxn
 *@Date 2022-10-11
 *@Version
 **/
public enum VideoBitrateEnum implements EnumInterface {
    // 720P-720P；1080P-1080P；2K-2K
    B_720P("720P", "720P"),
    B_1080P("1080P", "1080P"),
    B_2K("2K", "2K");

    VideoBitrateEnum(String code, String desc) {
        this.code = code;
        this.value = desc;
        this.desc = desc;
    }

    @EnumValue
    @JsonValue    //标记响应json值
    private final String code;
    private final String value;
    private final String desc;

    public String getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }
    public static VideoBitrateEnum getByCode(String code) {
        VideoBitrateEnum[] enums = VideoBitrateEnum.values();
        for (int i = 0; i < enums.length; i++) {
            if(enums[i].code.equals(code)){
                return enums[i];
            }
        }
        return null;
    }
    public static String getValueByCode(String code) {
        VideoBitrateEnum status = VideoBitrateEnum.getByCode(code);
        if(null == status){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        return status.getValue();
    }
    public static String getDescByCode(String code) {
        VideoBitrateEnum bitrate = VideoBitrateEnum.getByCode(code);
        if(null == bitrate){
            return code;
        }
        return bitrate.getDesc();
    }

    @Override
    public String desc() {
        return this.desc;
    }

    @Override
    public Integer value() {
        return null;
    }

    @Override
    public String code() {
        return this.code;
    }


}
